package org.datavis.chart;

import org.datavis.axis.ColumnChartHorizontalAxis;
import org.datavis.event.ChartTouchListener;
import org.datavis.event.ColumnChartOnClickListener;
import org.datavis.renderer.ColumnChartRenderer;
import android.content.Context;
import android.util.AttributeSet;

public class ColumnChart extends Chart {
	
	public ColumnChart(Context context, AttributeSet attrs) {
		super(context, attrs);
		if(this.zoomModus == Chart.ZOOMOUT)
			this.setOnClickListener(new ColumnChartOnClickListener(this, context, attrs));
		
    }
	
	public ColumnChart(Context context) {
		super(context);		
    }
	
	protected void initChartRenderer()
	{
		chartRenderer = new ColumnChartRenderer(getContext(), this);
		if(this.zoomModus == Chart.ZOOMIN)
			chartRenderer.setOnTouchListener(new ChartTouchListener(chartRenderer, this));
		super.initChartRenderer();
	}
	protected void initHorizontalAxis()
	{
		horizontalAxis = new ColumnChartHorizontalAxis(getContext(), this);
		super.initHorizontalAxis();
	}
	
	public void setZoomModus(int zoomModus) {
		super.setZoomModus(zoomModus);
		if(zoomModus == Chart.ZOOMOUT)
			this.setOnClickListener(new ColumnChartOnClickListener(this, getContext()));
		else if(zoomModus == Chart.ZOOMIN)
			chartRenderer.setOnTouchListener(new ChartTouchListener(chartRenderer, this));
	}
}
